<?php

namespace App\Services\Home;

use App\Models\Article;
use App\Models\Handroom;
use App\Models\Home\Property;

class ArticleService
{
    // 资讯详情
    public function getArticleDetail($id)
    {
        return Article::findOrfail($id);
    }
    // 资讯列表
    public function getArticleList($city)
    {
        return Article::latest()->with('tags')->whereIn('region_id',[0,$city])->paginate(10);
    }
    //热门楼盘
    public function getHotProperty($city)
    {
        return Property::latest()->where('region',$city)->where('recommend','like','%h%')->take(5)->get(['id','title','thumb','average','average_unit','areaname','town','opentime']);
    }
    // 推荐二手房
    public function getRecHandRoom($city)
    {
        return Handroom::where('region',$city)->where('rec','T')->take(5)->get(['id','title','thumb','price','acreage','areaname','town','renovation_name']);
    }
}